TCanvas c1;
gStyle->SetOptStat(0);

tree=newdraw_Tree

  //ExB
// TH2D *h2=new TH2D("h2","", 50, -0.6, 0.6,100,0,5)
//   h2->SetXTitle("atan(dy/dx) of first chamber")
//   h2->SetYTitle("Q55/<Q55>");
// tree->Draw("trdQ0/AliTRDdEdxBaseUtils::Q0MeanTRDpp(pow(10, ltbg)):dphi0>>h2","trdnch0==6","colz")

//ncls
 //  TH2D *h2=new TH2D("h2","", 50, -0.6, 0.6, 100, 80, 180)
//   h2->SetXTitle("atan(dy/dx) of first chamber")
//   h2->SetYTitle("N_{cls}");
// tree->Draw("trdncls0:dphi0>>h2","trdnch0==6","colz")

//QvsNcls
  TH2D *h2=new TH2D("h2","", 120, 60, 180, 100,0,5)
  h2->SetXTitle("N_{cls}")
  h2->SetYTitle("Q55/<Q55>");
tree->Draw("trdQ0/AliTRDdEdxBaseUtils::Q0MeanTRDpp(pow(10, ltbg)):trdncls0>>h2","trdnch0==6","colz")

h3=XGLUtils::NormalHist(h2,50,1)
h3->Draw("colz")
  gPad->SetGrid();
c1.Print("h2d.png");

TH1D *hnor=0, *hmpv=0, *hwid=0, *hres=0, *hchi=0;
XGLUtils::FitSlicesY(h2, 0x0, hnor, hmpv, hwid, hres, hchi, 50, 0, 0.99)

TH1D *hs[]={hnor, hmpv, hwid, hres, hchi};

//TFile *fout=new TFile("ExB.root","recreate");
TFile *fout=new TFile("ncls.root","recreate");
h2->Write();
h3->Write();

for(int ii=0; ii<5; ii++){
  hs[ii]->Draw();
  c1.Print(Form("%s.png",hs[ii]->GetName()));
  hs[ii]->Write();
 }

fout->Save();
fout->Close();
